package ch.lue.tvsedit.model;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

public class ChannelTable extends AbstractTableModel 
{
	private ArrayList<Channel> channels = new ArrayList<Channel>();
	
	@Override
	public String getColumnName(int column) {
		String ret = null;
		switch (column) {
		case 0:
			ret = "IdChannel";
			break;
		case 1:
			ret = "Name";
			break;

		default:
			break;
		}
		
		return ret;
	}
	
	public void add(Channel c) 
	{
		channels.add(c);
	}

	@Override
	public int getColumnCount() 
	{
		if(channels.size() == 0)
			return 0;
		
		return 2;
	}

	@Override
	public int getRowCount() {
		return channels.size();
	}

	@Override
	public Object getValueAt(int row, int col) 
	{
		Object ret = null;
		switch (col) {
		case -1:
			
			ret = channels.get(row);
			break;
		case 0:
			
			ret = channels.get(row).getIdChannel();
			break;
		case 1:
			ret = channels.get(row).getName();
			break;

		default:
			break;
		}
		
		return ret;
	}

}
